/***************************************************************
 *  Copyright (c) 2007 by GroupMe! Team (www.groupme.net)
 *  All rights reserved
 *
 *  This file is part of the GroupMe! Project. You can utilize
 *  software of the GroupMe! project under the terms of the 
 *  GNU Lesser General Public License as published by the
 *  Free Software Foundation in version 2.1.
 * 
 *  The GNU Lesser General Public License can be found at:
 *  http://www.gnu.org/licenses/lgpl.html
 *
 *  This copyright notice MUST APPEAR in all copies of the file!
 ***************************************************************/
package net.groupme.model;

import java.net.URI;
import java.util.Collection;

import net.groupme.exceptions.DeleteFailedException;
import net.groupme.exceptions.InsertFailedException;
import net.groupme.exceptions.UpdateFailedException;
import net.groupme.model.dao.UserDAO;

/**
 * Implementation of a GroupMe! user.
 * 
 * created on 16.04.2007
 * 
 * @author Mischa Frank - <a
 *         href="mailto:code@planetfrank.net">code@planetfrank.net</a>
 * @author Fabian Abel - <a href="mailto:abel@l3s.de">abel@l3s.de</a>
 * 
 * @version 0.1
 * 
 */
public class UserImpl implements User {

	private UserDAO userDao = null;

	public UserImpl(UserDAO userDao) {
		this.userDao = userDao;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#addGroup(net.groupme.model.Group,
	 *      java.lang.String)
	 */
	public void addGroup(Group group, String role) throws InsertFailedException {
		this.userDao.addGroup(group, role);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#addTag(net.groupme.model.Tag)
	 */
	public void addTag(Tag tag) {
		this.userDao.addTag(tag);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#addVisualization(net.groupme.model.GroupVisualization)
	 */
	public void addVisualization(GroupVisualization groupVisualization) {
		this.userDao.addVisualization(groupVisualization);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#checkPassword(java.lang.String)
	 */
	public boolean checkPassword(String password) {
		return this.userDao.checkPassword(password);
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object arg0) {
		if(arg0 instanceof User)
			return this.getURI().equals(((User)arg0).getURI());
		return false;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#getActualVisualization(net.groupme.model.Group)
	 */
	public GroupVisualization getActualVisualization(Group group) {
		return this.userDao.getActualVisualization(group);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.Identifiable#getDescription()
	 */
	public String getDescription() {
		return this.userDao.getDescription();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#getEmail()
	 */
	public String getEmail() {
		return this.userDao.getEmail();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#getFirstName()
	 */
	public String getFirstName() {
		return this.userDao.getFirstName();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#getGroups()
	 */
	public Collection<Group> getGroups() {
		return this.userDao.getGroups();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#getGroups(java.lang.String)
	 */
	public Collection<Group> getGroups(String role) {
		return this.userDao.getGroups(role);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.Identifiable#getLabel()
	 */
	public String getLabel() {
		return this.userDao.getLabel();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#getLastName()
	 */
	public String getLastName() {
		return this.userDao.getLastName();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#getTags()
	 */
	public Collection<Tag> getTags() {
		return this.userDao.getTags();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#getTags(net.groupme.model.Resource)
	 */
	public Collection<Tag> getTags(Resource taggedResource) {
		return this.userDao.getTags(taggedResource);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#getURI()
	 */
	public URI getURI() {
		return this.userDao.getURI();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#getUserName()
	 */
	public String getUserName() {
		return this.userDao.getUserName();
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#getFoaf()
	 */
	public String getFoaf() {
		return this.userDao.getFoaf();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#getVisualizations()
	 */
	public Collection<GroupVisualization> getVisualizations() {
		return this.userDao.getVisualizations();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#getVisualizations(net.groupme.model.Group)
	 */
	public Collection<GroupVisualization> getVisualizations(Group group) {
		return this.userDao.getVisualizations(group);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#removeGroup(net.groupme.model.Group)
	 */
	public void removeGroup(Group group) throws DeleteFailedException {
		this.userDao.removeGroup(group);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#removeTag(net.groupme.model.Tag)
	 */
	public void removeTag(Tag tag) {
		this.userDao.removeTag(tag);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#removeVisualization(net.groupme.model.GroupVisualization)
	 */
	public void removeVisualization(GroupVisualization groupVisualization) {
		this.userDao.removeVisualization(groupVisualization);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#setActualVisualization(net.groupme.model.Group,
	 *      net.groupme.model.GroupVisualization)
	 */
	public void setActualVisualization(Group group, GroupVisualization groupVisualization) throws UpdateFailedException {
		this.userDao.setActualVisualization(group, groupVisualization);		
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.Identifiable#setDescription(java.lang.String)
	 */
	public void setDescription(String description) throws UpdateFailedException {
		this.userDao.setDescription(description);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#setEmail(java.lang.String)
	 */
	public void setEmail(String email) throws UpdateFailedException {
		this.userDao.setEmail(email);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#setFirstName(java.lang.String)
	 */
	public void setFirstName(String firstname) throws UpdateFailedException {
		this.userDao.setFirstName(firstname);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.Identifiable#setLabel(java.lang.String)
	 */
	public void setLabel(String label) {
		this.userDao.setLabel(label);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#setLastName(java.lang.String)
	 */
	public void setLastName(String lastname) throws UpdateFailedException {
		this.userDao.setLastName(lastname);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.User#setPassword(java.lang.String)
	 */
	public void setPassword(String password) throws UpdateFailedException {
		this.userDao.setPassword(password);
	}

	public void setFoaf(String foaf) throws UpdateFailedException {
		this.userDao.setFoaf(foaf);
		
	}

	/* (non-Javadoc)
	 * @see net.groupme.model.User#getId()
	 */
	public String getId() {
		return this.userDao.getId();
	}

	/* (non-Javadoc)
	 * @see net.groupme.model.User#getPhoto()
	 */
	public String getPhoto() {
		return this.userDao.getPhoto();
	}

	/* (non-Javadoc)
	 * @see net.groupme.model.User#setPhoto(java.lang.String)
	 */
	public void setPhoto(String photo) {
		this.userDao.setPhoto(photo);
	}

	
}
